import QtQuick 2.0
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.15

import QtQuick.Window 2.1
import QtQuick.Controls.Material 2.1




ApplicationWindow {
    id: window
    visible: true
     menuBar: MenuBar {

        Menu {
            id:menu;
            title: "门诊登记";
            MenuItem{
                text: "添加";
                onTriggered: {

                    var tab = tabButton.createObject(tabBar, {text: text + tabBar.count})
                    tabBar.insertItem(tabBar.count,tab)
                    //设置当前新增tab页面的所在位置
                    tabBar.setCurrentIndex(tabBar.count-1)
                }


            }

        }
        Menu {
            id:menu2;
            title: "帮助";
            MenuItem{
                text: "关于";
                onTriggered: {

                    var tab = tabButton.createObject(tabBar, {text: text + tabBar.count})
                    tabBar.insertItem(tabBar.count,tab)
                    //设置当前新增tab页面的所在位置
                    tabBar.setCurrentIndex(tabBar.count-1)
                }

            }
            MenuItem{
                text: "官网";
                onTriggered: Qt.openUrlExternally("http://www.baidu.com");
            }
        }
    }
    TabBar {
        id:tabBar
        width: parent.width
        Component {
             id: tabButton
             TabButton {  }
         }
       }
//    Button{


//        onClicked: {
//                   var tab = tabButton.createObject(tabBar, {text: "Tab " + tabBar.count})
//                   tabBar.addItem(tab)
//               }
//    }
}


